package com.bob.debt.utils;

import com.bob.debt.entity.base.*;

/**
 * 参数工具类
 *
 * @author chao.wang
 */
public class ParamUtil {

    /**
     * 报文请求头填充交易双方信息
     *
     * @param applicationHeader 请求头
     * @param fromId            发起方客户编号
     * @param toId              接收方客户编号
     */
    public static void generateApplicationHeader(ApplicationHeader applicationHeader, String fromId, String toId) {
        applicationHeader.setFrom(getMechanismInfo(fromId));
        applicationHeader.setTo(getMechanismInfo(toId));
    }

    /**
     * 创建交易双方Bean
     *
     * @param counterpartyId 交易方客户编号
     * @return 交易方Bean
     */
    private static MechanismInfo getMechanismInfo(String counterpartyId) {
        FinancialInstitutionOther financialInstitutionOther = FinancialInstitutionOther.builder().id(counterpartyId).build();
        FinancialInstitutionId financialInstitutionId = FinancialInstitutionId.builder().other(financialInstitutionOther).build();
        FinancialInstitutionIdDomain financialInstitutionIdDomain = FinancialInstitutionIdDomain.builder().financialInstitutionId(financialInstitutionId).build();
        return MechanismInfo.builder().financialInstitutionIdDomain(financialInstitutionIdDomain).build();
    }

}
